import java.util.Scanner;

public class step2_2 {
    String []name =new String[100];
    String []sex = new String[100];
    int []number = new int[100];
    String []local = new String[100];
    public void print(int num){
        System.out.println("编号      姓名      性别      电话      通信地址");
        for (int i=0;i<num; i++)
            if (!name[i].equals("#"))
            System.out.println(i+"      "+name[i]+"      "+sex[i]+"        "+number[i]+"    "+local[i]);
    }
    public void print(String aaa)
    {
        System.out.print(aaa);
    }
    public void add (int n)
    {
     Scanner na = new Scanner(System.in);
     print("姓名");
     name[n]=na.next();
        Scanner se = new Scanner(System.in);
        print("sex");
        sex[n]=se.next();
        Scanner nu = new Scanner(System.in);
        print("number");
        number[n]=nu.nextInt();
        Scanner lo = new Scanner(System.in);
        print("local");
        local[n]=lo.next();
    }
    public void search(int num)
    {
        Scanner iname = new Scanner(System.in);
        print("请输入您要查询的人的姓名：");
        String fname =iname.next();
        int i;
        for (i=0;i<num;i++)
        {
            if (fname.equals(name[i]))
            {
                System.out.println("编号      姓名      性别      电话      通信地址");
                System.out.println(i+"      "+name[i]+"      "+sex[i]+"        "+number[i]+"    "+local[i]);
                break;
            }
        }
        if (i==num)
            print("not find");
    }
     public void delect(int num) {
        int i;
        Scanner sdel = new Scanner(System.in);
        print("输入想要删除的人的名字");
        String del = sdel.next();
        for (i = 0; i < num; i++)
            if (del.equals(name[i])) {
                name[i]="#";
                break;
            }
            if (i==num)
                print("not find!");
    }
    public void xiugai(int num)
    {
        int i,n;

        Scanner sxiu = new Scanner(System.in);
        print("输入需要修改的人的名字：");
        String xiun = sxiu.next();
        for (i=0;i<num;i++)
            if (xiun.equals(name[i]))
                break;
        if (i==num)
            print("not find");
        else
        {
            Scanner xiua =new Scanner(System.in);
            print("1性别  2电话 3通信地址");
            n=xiua.nextInt();
            switch (n)
            {
                case 1:{
                    Scanner xiua1 =new Scanner(System.in);
                    print("请输入想要修改为：");
                    String xiu = xiua1.next();
                    sex[i]=xiu;
                }break;
                case 2:{
                    Scanner xiua1 =new Scanner(System.in);
                    print("请输入想要修改为：");
                    int xiu = xiua1.nextInt();
                    number[i]=xiu;
                }break;
                case 3:{
                    Scanner xiua1 =new Scanner(System.in);
                    print("请输入想要修改为：");
                    String xiu = xiua1.next();
                    local[i]=xiu;
                }break;
            }
        }
    }
    public static void main(String[] args) {
        int i,num;
        step2_2 a=new step2_2();
        Scanner nuu = new Scanner(System.in);
        a.print("请输入添加的人数：");
        num=nuu.nextInt();
        for (i=0;i<num;i++)
            a.add(i);
        a.print(num);
        while (true)
        {
            a.print("1显示 ");
            a.print("2查询");
            a.print("3增加");
            a.print("4修改");
            a.print("5删除");
            a.print("0退出");
            Scanner aaaa =new Scanner(System.in);
            int status=aaaa.nextInt();
            if(status==0)
                break;
            switch (status) {
                case 1:
                    a.print(num);
                    break;
                case 2:
                    a.search(num);
                    a.print(num);
                    break;
                case 3:
                    a.add(num);
                    num = num + 1;
                    a.print(num);
                    break;
                case 4:
                    a.xiugai(num);
                    a.print(num);break;
                case 5:
                    a.delect(num);a.print(num);break;
            }}}}